<?php

include '../../../configuration.php';

include 'sorting.php';


$smarty->template_dir = LOCAL_PATH.'administrator/main/templates/';
$smarty->compile_dir = LOCAL_PATH.'administrator/main/templates_c/';
$smarty->config_dir = LOCAL_PATH.'administrator/main/configs';

$smarty->compile_check = true;
//$smarty->debugging = true;
$faculties = array();
$ufaculties = array();

$id = array();
$name = array();
$surname = array();
$ulogin = array();
$group_id = array();
$faculty_id = array();
$groups = array();
$ugroups = array();
$cdate = array();
$vdate = array();

$groups = array("<option value='all'>All groups</option>");

while ($rows = mysql_fetch_array($result,MYSQL_ASSOC)){
	$id[] = $rows["id"];
	$name[] = $rows["u_name"];
	$surname[] = $rows["u_surname"];
	$group_id[] = $rows["group_id"];
	$faculty_id[] = $rows["faculty_id"];
	$ugroups[] = $rows["group_name"];
	$ulogin[] = $rows["u_login"];
	$cdate[] = $rows["u_registerdate"];
	$vdate[] = $rows["u_lastvisitdate"];	
}


$faculties = array("<option value='all'>All faculties</option>");
$result4 = mysql_query("SELECT * FROM `faculties`");
$result2 = mysql_query("SELECT * FROM `groups`");
while($rows3 = mysql_fetch_array($result2,MYSQL_ASSOC)){
	$selected = '';
	if ($_SESSION['selected_group']==$rows3["group_id"]){
		$selected = "selected='true'";
	}
	$groups[] = "<option value='".$rows3["group_id"]."' $selected >".$rows3["group_name"]."</option>";
}
while ($rows4 = mysql_fetch_array($result4,MYSQL_ASSOC)) {
	$selected = '';
	if($_SESSION['selected_f'] == $rows4["faculty_id"]){
		$selected = "selected='true'";
	}
	$faculties[] = "<option value='".$rows4["faculty_id"]."' $selected >".$rows4["faculty_name"]."</option>";
	for($i = 0; $i < count($faculty_id); $i++){
		if ($faculty_id[$i] == $rows4["faculty_id"]) $ufaculties[] = $rows4["faculty_name"];
	}
}

$result5 = mysql_query($t_sql);
$rows5 = mysql_num_rows($result5);
$_SESSION['q_count'] = $rows5;

$pages = ceil($_SESSION['q_count']/$_SESSION['m_limit']);

$smarty->assign('id',$id);
$smarty->assign('name',$name);
$smarty->assign('surname',$surname);
$smarty->assign('login',$ulogin);
//$smarty->assign('f_title',$f_title);
$smarty->assign('cdate',$cdate);
$smarty->assign('vdate',$vdate);
$smarty->assign('limit',$_SESSION['m_limit']);
$smarty->assign('comp',$_SESSION['selected_comp']);
$smarty->assign('selected_group',$_SESSION['selected_group']);
$smarty->assign('groups',$groups);
$smarty->assign('ugroups',$ugroups);
$smarty->assign('faculties',$faculties);
$smarty->assign('ufaculties',$ufaculties);
$smarty->assign('pages',$pages);

include '../../check.php';
if ($checking == 1)
	$smarty->display('modify_or_delete_user.tpl');
else echo "You are not autorised"; exit;

?>
